package item;

import loadsave.Memento;
import loadsave.loadsaveobject.LoadSaveObject;

public class Obstacle extends Item {

    public Obstacle( String name ) {
        super(name);
    }
    
    public void accept( visitors.ItemVisitor iv ) {
        iv.visitObstacle(this);
    }
    
    /**
     * overridden so that you can't walk on obstacles
     */
    public boolean canBeWalkedOn() {
        return false;
    }

    @Override
    public Memento getMemento() {
        return new Memento() {

			@Override
			public LoadSaveObject getState() {
				LoadSaveObject toReturn = Obstacle.super.getMemento().getState();
				toReturn.setType("Obstacle");
				return toReturn;
			}

			@Override
			public void restoreState(LoadSaveObject lso) {
				Obstacle.super.getMemento().restoreState(lso);
			}
        	
        };
    }
    
    public Obstacle() { }
    
    @Override
	public Obstacle clone() {
		Obstacle toReturn = new Obstacle();
		toReturn.getMemento().restoreState(this.getMemento().getState());
		return toReturn;
	}

}
